package com.hs.communication.common.config;

import com.hs.common.core.constant.CacheConstants;
import com.hs.common.redis.service.RedisService;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.HashMap;

@Component
public class HeartbeatMap {

    @Resource
    private RedisService redisService;

    @PostConstruct
    public void init() throws InterruptedException {
        System.out.println("初始化");
        if (redisService.getCacheMap(CacheConstants.DEVICE_HEARTBEAT_TIME_KEY) == null) {
            redisService.setCacheMap(CacheConstants.DEVICE_HEARTBEAT_TIME_KEY, new HashMap<String, LocalDateTime>());
        }
        System.out.println("初始化结束");
    }
}
